package com.trt.eatmeat.test;

import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;

import java.util.HashMap;
import java.util.Map;

/**
 *  业务工具类
 */
public class HttpViKaUtil {

    public static String domain="https://api.vika.cn/fusion/v1/";
    public static String token  ="uskdkmzTG2FMoKShcwQcQJk";
    public static  String spaceId="spcpVsdZAt971";
    public static String nodeId="dsttKCJP0WaxSXjGfA";
    public static String viewId="viwx4gZXlVx4B";
    public static String recordUrlList=domain+"datasheets/"+HttpViKaUtil.nodeId+"/records?viewId="+HttpViKaUtil.viewId+"&fieldKey=name&pageNum=1&pageSize=30&sort={\"field\": \"创建时间\", \"order\": \"desc\"}&filterByFormula=find(\"%s\", {员工}) > 0";
    public static String recordUrlCreate=domain+"datasheets/"+HttpViKaUtil.nodeId+"/records";


    /**
     * 内网请求post
     * @param url
     * @param json
     * @return
     */
    public static String post(String url, String json){
        String response= HttpRequest.post(url)
                .header(Header.CONTENT_TYPE,"application/json")
                .header("Authorization","Bearer "+HttpViKaUtil.token)
                .body(json).execute().body();
        return response;
    }
    /**
     * 内网请求get
     * @param url
     * @return
     */
    public static String get(String url){
        String response= HttpRequest.get(url)
                .header("Authorization","Bearer "+HttpViKaUtil.token)
                .execute().body();
        return response;
    }

}
